/**
 * 
 */
package org.log4jconfig.xml.editor.contentassist.attribute;

import java.util.List;

import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.ui.ISharedImages;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.log4jconfig.xml.editor.utils.ContentAssistRequestUtils;
import org.log4jconfig.xml.editor.utils.Logger;

/**
 * @author Xi
 * 
 */
@SuppressWarnings("restriction")
public class AppenderRefRefComputer extends AbstractContentAssistComputer {

	/**
	 * Scan the whole document, looking for all <appender> elements and
	 * proposing their 'name' attribute to the content assistant
	 */
	public void addAttributeValueProposals(IJavaProject javaProject, ContentAssistRequest contentAssistRequest,
			String attributeCurrentValue, String attributeMatchValue) throws Exception {
		List<String> names = ContentAssistRequestUtils.findAllAppenderNames(contentAssistRequest);
		if (names == null || names.size() == 0) {
			Logger.warn("No appender found in the current log4j.xml config file");
		}
		for (String name : names) {
			addCompletionProposal(contentAssistRequest, name, attributeCurrentValue, attributeMatchValue,
					ISharedImages.IMG_OBJS_DEFAULT);
		}
	}

}
